<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{msg.regNegozio}</title>
    </h:head>
    <h:body>
        <div class="container">
            <ui:include src="Header.xhtml"/>
            <div class="content">
                <h3>#{msg.regNegozio}:</h3>
                <p:messages autoUpdate="true" closable="true"/>
                <h:form>
                    <h:panelGrid id="grid" columns="2">
                        <p:outputLabel for="nome" value="#{msg.nomeForm}"/>
                        <p:inputText id="nome" required="true" requiredMessage="#{msg.nomeRequiredM}" value="#{registrazioneNegozio.nome}"/>
                        
                        <p:outputLabel for="provincia" value="#{msg.provinciaForm}"/>
                        <p:selectOneMenu id="provincia" required="true" requiredMessage="#{msg.provinciaRequiredM}"
                                         value="#{provinciaComuni.provincia}" converter="provinciaConverter">
                            <f:selectItem itemValue="" itemLabel="#{msg.selProvincia}" noSelectionOption="true"/>
                            <f:selectItems value="#{provinciaComuni.province}" var="p" itemLabel="#{p.nome},#{p.abbreviazione}" itemValue="#{p}"/>
                            <p:ajax event="valueChange" update="comuni" listener="#{provinciaComuni.handleComuni()}" />
                        </p:selectOneMenu>

                        <p:outputLabel for="comuni" value="#{msg.comuneForm}"/>
                        <p:selectOneMenu id="comuni" required="true" requiredMessage="#{msg.comuneRequiredM}" 
                                         value="#{provinciaComuni.comune}" converter="comuneConverter">
                            <f:selectItem itemLabel="#{msg.selComune}" itemValue="" noSelectionOption="true"/>
                            <f:selectItems value="#{provinciaComuni.comuni}" var="c" itemLabel="#{c.nome},#{c.cap}" itemValue="#{c}"/>
                        </p:selectOneMenu>
                        
                        <p:outputLabel for="marchio" value="#{msg.marchioForm}"/>
                        <p:selectOneMenu required="true" id="marchio" requiredMessage="#{msg.marchioRequestM}" converter="marchioConverter" var="mar" value="#{marchiSelector.marchioSel}">
                            <f:selectItem itemLabel="#{msg.selMarchio}" itemValue=""/>
                            <f:selectItems value="#{marchiSelector.marchi}" var="m" itemLabel="#{m.nome}" itemValue="#{m}"/>
                            <p:column>  
                                <p:graphicImage value="#{mar.foto.fotoPath()}" width="50" height="50"/>  
                            </p:column>  
                            <p:column>  
                                #{mar.nome}  
                            </p:column>
                        </p:selectOneMenu>
                        
                    </h:panelGrid> 
                    <p:commandButton update="grid" action="#{registrazioneNegozio.registra(provinciaComuni,marchiSelector)}" value="#{msg.confermaDati}"/>
                </h:form>
            </div>
            <ui:include src="Footer.xhtml"/>
        </div>
    </h:body>
</html>

